import {getNextImage} from "@/components/page/PhotoPage3/PhotoController";

export const changeTime = 5000 // 切换图片间隔时间
export const removeTime = 2000 // 切换图片过程

export const init = (container: HTMLDivElement) => {

    let timer = null;
    const process = async () => {
        const img = await getNextImage()
        img.addToContainer(container)
        img.setBottom()
        setTimeout(() => {
            img.setFront()
        }, changeTime / 2)
        timer = setTimeout(() => {
            process().then(img.remove)
        }, changeTime)
    }

    process().then()

    return () => {
        window.clearTimeout(timer)
        container.innerHTML = null
        console.log(timer)
    }
}